package com.bytedance.improvingroad.activity

import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import com.bytedance.improvingroad.R
import com.bytedance.improvingroad.databinding.ActivityMDBinding

class MDActivity : BaseBindingActivity<ActivityMDBinding>() {

    override fun initData() {
        //关联toolBar和菜单
        setSupportActionBar(binding.toolBar)
    }

    override fun initListener() {
        binding.navView.setNavigationItemSelectedListener { menuItem->
            binding.drawer.closeDrawers()
            //返回true标识点击之后一直选中该menu
            false
        }
    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.action_bar_menu,menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        item.title.toString().showToast()
        return true
    }
    fun String.showToast() {
        Toast.makeText(this@MDActivity,this,Toast.LENGTH_SHORT).show()
    }
}